﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.net.URLEncoder" %>
<%@ page import="java.net.URLDecoder" %>
<%@ page import="com.model.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" rev="stylesheet" href="../css/style.css" type="text/css" media="all" />
<style type="text/css">
<!--
.atten {font-size:12px;font-weight:normal;color:#F00;}
-->
</style>

<script>
function save(){
	if(document.form.lpn.value == null || document.form.lpn.value == ""){
		alert("车牌必须填写");
		document.form.lpn.focus();
		return;
	}
	else if(document.form.model.value == null || document.form.model.value == ""){
		alert("车辆型号必须填写");
		document.form.model.focus();
		return;
	}
	else if(document.form.user.value == null || document.form.user.value == ""){
		alert("借车人必须填写");
		document.form.user.focus();
		return;
	}
	else if(document.form.to.value == null || document.form.to.value == ""){
		alert("目的地必须填写");
		document.form.to.focus();
		return;
	}
	else if(confirm("确认出车？")){
		document.form.submit();			
	}
}
</script>
</head>

<body class="ContentBody">
<%
	request.setCharacterEncoding("UTF-8");
	response.setCharacterEncoding("UTF-8");

	Connection con = DataBase.getConnection();
	
	PreparedStatement pstmtInfo = con.prepareStatement("SELECT * FROM car WHERE lpn=?");
	String lpn = request.getParameter("lpn");
	if(lpn!=null)
		lpn = URLDecoder.decode(lpn, "UTF-8");
	else
		lpn="";
	pstmtInfo.setString(1, lpn);
	ResultSet rsInfo = pstmtInfo.executeQuery();
	if(!rsInfo.next())
	{%>
<form action="CarDeal?flag=out" method="post" name="form" >
	<div class="MainDiv">
		<table width="99%" border="0" cellpadding="0" cellspacing="0" class="CContent">
		 	<tr>
				<th class="tablestyle_title" >出车申请</th>
			</tr>
			<tr>
				<td class="CPanel">
					<table border="0" cellpadding="0" cellspacing="0" style="width:100%">
						<tr>
							<td width="100%">
								<fieldset style="height:100%;">
								<legend>车辆信息</legend>
								<table border="0" cellpadding="2" cellspacing="1" style="width:100%">
									<tr>
										<td nowrap="nowrap" align="right" width="15%">车牌号:</td>
										<td width="35%"><input name="lpn" type="text" class="text" style="width:154px" value="" />
										<span class="red"></span></td>
										<td nowrap="nowrap" align="right" width="18%">借车人:</td>
										<td width="35%"><input name="user" type="text" class="text" style="width:154px" value="" />
										<span class="red"></span></td>
									</tr>
									<tr>
										<td nowrap="nowrap" align="right" width="15%">车辆型号:</td>
										<td width="35%"><input type="text" name="model" class="text" style="width:154px" value="" />
										<span class="red"></span></td>
										<td nowrap="nowrap" align="right" width="18%">所属部门:</td>
										<td width="35%"><input name="dptmt" type="text" class="text" style="width:154px" value="" />
										<span class="red"></span></td>		
									</tr>
									<tr>	
										<td nowrap="nowrap" align="right" width="15%">出发地:</td>
										<td width="35%"><input name="from" type="text" class="text" style="width:154px" value="" />
										<span class="red"></span></td>
										<td nowrap="nowrap" align="right">出发事由:</td>
										<td><input name="reason" type="text" class="text" style="width:154px" value="" />
										<span class="red"></span></td>
									</tr>
									<tr>
										<td nowrap="nowrap" align="right">目的地:</td>
										<td><input name="to" type="text" class="text" style="width:154px" value="" />
										<span class="red"></span></td>
										<td nowrap="nowrap" align="right">出发时间:</td>
										<td><input name="time" type="text" class="text" style="width:154px" value="" /> 
										<span class="red"></span></td>
									</tr>
									<tr>
										<td width="15%" nowrap="nowrap" align="right">备注:</td>
										<td colspan="3"><textarea name="memo" cols="100" rows="10"></textarea></td>
									</tr>
								</table><br /></fieldset>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center" height="50px">
					<input type="button" name="Submit" value="出车" class="button" onclick="save()"/>
					<input type="button" name="Submit2" value="取消" class="button" onclick="window.history.go(-1);"/>
				</td>
			</tr>
		</table>
	</div>
</form>		
	<%}
	else{%>

<form action="CarDeal?flag=out" method="post" name="form" >
	<div class="MainDiv">
		<table width="99%" border="0" cellpadding="0" cellspacing="0" class="CContent">
			<tr>
				<th class="tablestyle_title" >出车申请</th>
			</tr>
			<tr>
				<td class="CPanel">
					<table border="0" cellpadding="0" cellspacing="0" style="width:100%">
						<tr>
							<td width="100%">
								<fieldset style="height:100%;">
								<legend>车辆信息</legend>
								<table border="0" cellpadding="2" cellspacing="1" style="width:100%">
									<tr>
										<td nowrap="nowrap" align="right" width="15%">车牌号:</td>
										<td width="35%"><input name="lpn" type="text" class="text" style="width:154px" value="<%=rsInfo.getString("lpn") %>" readonly="readonly"/>
										<span class="red"></span></td>
										<td nowrap="nowrap" align="right" width="18%">借车人:</td>
										<td width="35%"><input name="user" type="text" class="text" style="width:154px" value="" />
										<span class="red"></span></td>
									</tr>
									<tr>
										<td nowrap="nowrap" align="right" width="15%">车辆型号:</td>
										<td width="35%"><input type="text" name="model" class="text" style="width:154px" value="<%=rsInfo.getString("model") %>" readonly="readonly" />
										<span class="red"></span></td>
										<td nowrap="nowrap" align="right" width="18%">所属部门:</td>
										<td width="35%"><input name="dptmt" type="text" class="text" style="width:154px" value="" /></td>		
									</tr>
									<tr>	
										<td nowrap="nowrap" align="right" width="15%">出发地:</td>
										<td width="35%"><input name="from" type="text" class="text" style="width:154px" value="" /></td>
										<td nowrap="nowrap" align="right">出发事由:</td>
										<td><input name="reason" type="text" class="text" style="width:154px" value="" /></td>
									</tr>
									<tr>
										<td nowrap="nowrap" align="right">目的地:</td>
										<td><input name="to" type="text" class="text" style="width:154px" value="" />
										<span class="red"></span></td>
										<td nowrap="nowrap" align="right">出发时间:</td>
										<td><input name="time" type="text" class="text" style="width:154px" value="" /></td>
									</tr>
									<tr>
										<td width="15%" nowrap="nowrap" align="right">备注:</td>
										<td colspan="3"><textarea name="memo" cols="100" rows="10"></textarea></td>
									</tr>
								</table>
								<br /></fieldset>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center" height="50px">
					<input type="button" name="Submit" value="出车" class="button" onclick="save()"/>
					<input type="button" name="Submit2" value="取消" class="button" onclick="window.history.go(-1);"/>
				</td>
			</tr>
		</table>
	</div>
</form>
<%}
	rsInfo.close();
	con.close();
%>
</body>
</html>
